from flask_shop import db
from werkzeug.security import generate_password_hash,check_password_hash
from datetime import datetime
class User(db.Model):
    __tablename__="t_user"
    id = db.Column(db.Integer,primary_key=True,autoincrement=True)
    uname = db.Column(db.String(32),unique=True)
    nick_name= db.Column(db.String(32))
    pwd = db.Column(db.String(120))
    phone = db.Column(db.String(11))
    email = db.Column(db.String(32))
    creat_time = db.Column(db.DateTime,default=datetime.now)
    updata = db.Column(db.DateTime,default=datetime.now,onupdate=datetime.now())



    @property
    def password(self):
        return self.pwd
    @password.setter
    def password(self,t_pwd):
        self.pwd=generate_password_hash(t_pwd)
    def yanz(self,t_pwd):
        return check_password_hash(self.pwd,t_pwd)

